<?php

/**
 * feed actions.
 *
 * @package    Redsea20
 * @subpackage feed
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class feedActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    //$this->forward('default', 'module');
      return sfView::SUCCESS;
  }
 
  
  public function executeLastPosts()
    {
      $feed = new sfAtom1Feed();

      $feed->setTitle('RBIS');
      $feed->setLink('http://rbis.kaust.edu.sa/');
      $feed->setAuthorEmail('rbis.kaust@gmail.com');
      $feed->setAuthorName('RBIS TEAM');

      $tmpResearches = Doctrine_Query::create()
                        ->select('r.*')
                        ->from('Research r')
                        ->where('r.entityid=6')
                        ->execute();

      foreach ($tmpResearches as $research)
      {
        $item = new sfFeedItem();
        $item->setTitle($research->getTitle());
        $item->setLink('@research?stripped_title='.RBISUtility::stripText($research->getTitle()));
        $item->setAuthorName($research->getEntity()->getFirstname());
        $item->setAuthorEmail('ali.nawaz82@gmail.com');
        //$item->setPubdate($research->getCreatedAt('U'));
        $item->setUniqueId(RBISUtility::stripText($research->getTitle()));
        $item->setDescription($research->getCitation());

        $feed->addItem($item);
      }

      $this->feed = $feed;
      //return sfView::SUCCESS;
        //$this->feed = sfFeedPeer::createFromWeb('http://groups.google.com/group/symfony-users/feed/rss_v2_0_msgs.xml');
    }
}
